//
//  SNPlanListButton.m
//  ZhuoxinAgriculture
//
//  Created by stone on 16/12/25.
//  Copyright © 2016年 stone. All rights reserved.
//

#import "SNPlanListButton.h"

@interface SNPlanListButton()
/** contentInset */
@property (nonatomic, assign) UIEdgeInsets contentInset;
@end
@implementation SNPlanListButton

//- (void)drawRect:(CGRect)rect {
//
//    UIEdgeInsets insets = {_PADDING,_PADDING, _PADDING, _PADDING};
//    return [super drawRect:UIEdgeInsetsInsetRect(rect, insets)];
//}
- (CGSize)intrinsicContentSize {
    CGSize intrinsicSuperViewContentSize = [super intrinsicContentSize] ;
    intrinsicSuperViewContentSize.width += (4 + 4 + 6) ;
    intrinsicSuperViewContentSize.height += (4 + 4 + 6);
    return intrinsicSuperViewContentSize ;
}
-(void)setPADDING:(CGFloat)PADDING{
    _PADDING = PADDING;
    
    //    [self setNeedsDisplay];
    //    CGFloat padding = 10.0f;
    //    [self setTitleEdgeInsets:UIEdgeInsetsMake(0, _PADDING, 0, -PADDING)];
    // 6
    [self setImageEdgeInsets:UIEdgeInsetsMake(0, -3, 0, 3)];
    [self setTitleEdgeInsets:UIEdgeInsetsMake(0, 3, 0, -3)];
    [self setContentEdgeInsets:UIEdgeInsetsMake(4, 4, 4, 4)];
    [self invalidateIntrinsicContentSize];
    
}
// 50 - (22+22)
/**
 *  设置边框宽度
 *
 *  @param borderWidth 可视化视图传入的值
 */
- (void)setBorderWidth:(CGFloat)borderWidth {
    
    if (borderWidth < 0) return;
    
    self.layer.borderWidth = borderWidth;
}

/**
 *  设置边框颜色
 *
 *  @param borderColor 可视化视图传入的值
 */
- (void)setBorderColor:(UIColor *)borderColor {
    
    self.layer.borderColor = borderColor.CGColor;
}

/**
 *  设置圆角
 *
 *  @param cornerRadius 可视化视图传入的值
 */
- (void)setCornerRadius:(CGFloat)cornerRadius {
    
    self.layer.cornerRadius = cornerRadius;
    self.layer.masksToBounds = cornerRadius > 0;
}

@end
